﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RoadTeam.SysInterface;
using System.Data;
using RoadTeam.Model;
using RoadTeam.Enums;

namespace RoadTeam.BsSystem.CS.Maintenance
{
   public  class CsMaintenance_Sys : ICsMaintenance
    {
       public bool InsertCsMaintenance(DataTable dt)
        {
           return  TbCsMaintenance.InsertDatatable(dt, GlobalConfig.RtConnectionString);
        }

       public  DataTable GetEmptyTable()
        {
            SqlWhere where = new SqlWhere();
            where.Info = new TbCsMaintenance() { MaintenanceID = "-1" };
            where.SelectColumn = @" SubCode,CreateDate,ServType,Content,Linkman,LinkTel,UnitFullName,StaffName,Remark,App_Identities,OrganID,UnitID";
            return TbCsMaintenance.Select(where, GlobalConfig.RtConnectionString);
        }

       public DataTable GetMaintenanceByIdentities(String Identities)
       {
           SqlWhere where = new SqlWhere();
           where.StrSqlWhere = @" App_Identities IN (" + Identities + ")";
           where.SelectColumn = @" MaintenanceID,App_Identities ";
           return TbCsMaintenance.Select(where, GlobalConfig.RtConnectionString);
       }

       public String GetSingleMaintenanceByIdentities(String Identities)
       {
           SqlWhere where = new SqlWhere();
           where.StrSqlWhere = @" App_Identities ='" + Identities+"'";
           where.SelectColumn = @" Top 1 MaintenanceID ";
           DataTable dt= TbCsMaintenance.Select(where, GlobalConfig.RtConnectionString);

           if (dt.Rows.Count == 0) return String.Empty;
           return dt.Rows[0][0].ToString();
       }
    }
}
